<template>
  <div>
    <div class="userContent">
      <el-row>
        <el-col :span="12">
          <el-form ref="form" :model="form" label-width="100px">
            <el-form-item prop="title" label="标题">
              <el-input v-model="form.title" disabled></el-input>
            </el-form-item>
            <el-form-item prop="tag_id" label="任务类别">
              <el-input v-model="form.tag_id" disabled></el-input>
            </el-form-item>
            <el-form-item prop="date" label="发布日期">
              <el-input v-model="form.date" disabled></el-input>
            </el-form-item>
            <el-form-item prop="content" label="任务内容">
              <el-input type="textarea" :autosize="{minRows:1,maxRows:50}" v-model="form.content" disabled></el-input>
            </el-form-item>
            <el-form-item prop="publisherName" label="发布者">
              <el-input v-model="form.publisherName" disabled></el-input>
            </el-form-item>
            <el-form-item prop="reward" label="酬金">
              <el-input v-model="form.reward" disabled></el-input>
            </el-form-item>
            <el-form-item prop="phone" label="电话号码">
              <el-input v-model="form.phone" disabled></el-input>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>

    </div>
  </div>
</template>

<script>
export default {
  name: `ReadTask`,
  data () {
    return {
      id: this.$route.params.id,
      form: {
        title: 'abc',
        tag_id: 0,
        date: '2021.11.23',
        content: 'gfds',
        publisherName: 'trew',
        reward: 10,
        phone: '8526385'
      }
    }
  },
  methods: {
    getTaskData (id) {
      if (id === null) {
        return this.$router.push({
          path: '/TaskList'
        })
      }
      this.$axios({
        url: `user/task/tasks/{id}`,
        method: 'get',
        data: {
          id: this.id
        }
      }).then(res => {
        if (res.data.status === 200) {
          this.form = res.data.data
        } else {
          alert('获取失败')
        }
      }).catch(err => {
        alert(err)
      })
    }
  },
  created () {
    this.getTaskData(this.$route.params.id)
  }
}
</script>

<style scoped>
.userContent {
  margin: 0 auto;
}

.el-input.is-disabled .el-input__inner {
  background-color: #ffffff;
  border-color: #ffffff;
  color: #222;
  cursor: pointer;
}

.el-textarea.is-disabled .el-textarea__inner {
  background-color: #ffffff;
  border-color: #ffffff;
  color: #222;
  cursor: pointer;
}
</style>
